package com.ymatou.iapi.captcha.testcase;

import java.io.File;
import java.util.Date;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.ymatou.iapi.captcha.parameter.*;
import com.ymatou.iapi.captcha.service.*;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.ValidateCodeServiceV2;
import com.ymttest.database.model.YmtValidationCode;
import com.ymttest.database.sqlwapper.YmtValidationCodeWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;
/**
*获取验证码（字符串）用例
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetCode{
	private static GetCodeBean GetCodeBean;
	private static GetCodeCall GetCodeCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取验证码（字符串）用例");
	}

	@Before
	public void caseUp() {
		GetCodeBean=new GetCodeBean();
		GetCodeCall=new GetCodeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(GetCodeCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetCode_001() {
		Logger.start(true,"获取图片验证码");
		try {
			String guid="1234";
			GetCodeBean.setGuid(guid);
			GetCodeCall.setData(GetCodeBean);
			GetCodeCall.callService();		
			Logger.comment(String.valueOf(GetCodeCall.getStatusCode()));
			Logger.comment("file:"+GetCodeCall.getFile());
			
			GetCodeCall.getAllHeader().forEach(header->{
				Logger.comment(header);
			});
			Logger.verifyEquals(true, TestDataManager.isPic(new File(GetCodeCall.getFile())), "验证是否是图片");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}